package com.cnr.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.cnr.model.Credentials;

@Controller
@RequestMapping("/logout")
public class LogoutController {

	@RequestMapping(method = RequestMethod.GET)
	public String logout(HttpSession session, Model model) {
		Credentials user = (Credentials) session.getAttribute("user");
		session.invalidate();
		model.addAttribute("message", user.getUsername() + " logged out!");
		return ("welcome");
	}
}